package com.szrt.java.day20170112.demo06;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;

import org.junit.Test;

public class InputStreamReaderTest {

	@Test
	public void inputStreamReader() throws IOException{
		
		File file = new File("src/com/szrt/java/day20170112/demo06/zp.txt");
		
		InputStream in = new FileInputStream(file);
		
		InputStreamReader isr = new InputStreamReader(in);
		
		char[] c = new char[5];
		
		int len;
		int counter = 0;
		while((len = isr.read(c)) != -1){
			counter++;
			String str = new String(c,0,len);
			System.out.print(str);
		}
		System.out.println(counter);
		isr.close();
		in.close();
	}
	
}
